import { Response } from '@/service/models/BaseModel'
import { LoginFormData, User } from '@/service/models/UserModel'

class UserApi {
  async login(formData: LoginFormData): Promise<Response<string>> {
    return new Promise(resolve => {
      setTimeout(() => {
        if (formData.username === 'renzhao' && formData.password === '666666') {
          resolve({
            success: true,
            data: 'sds0d-dfa0ds-00sd',
          })
        } else {
          resolve({
            success: false,
            message: 'user not found',
          })
        }
      }, 500)
    })
  }

  async getUserInfo(): Promise<Response<User>> {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          success: true,
          data: {
            name: '人找找',
            role: 'admin',
          },
        })
      }, 500)
    })
  }
}

export default new UserApi()
